﻿using System.Web;
using System.Web.SessionState;
using CustomerContactSystem.Core.Infrastructure.Configuration;
using StructureMap;

namespace CustomerContactSystem.WebForms
{
    /// <summary>
    /// Summary description for Logout
    /// </summary>
    public class Logout : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context) {
            var settings = ObjectFactory.GetInstance<IApplicationSettings>();

            if (context.Session[settings.UserSessionKey] != null) {
                context.Session.Remove(settings.UserSessionKey);
            }
            
            context.Response.Redirect("Login.aspx");
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}